﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ReliableSession.src
{
    /// <summary>
    /// Statistics like, number of bytes sent/ received etc.
    /// </summary>
    public class TransportStatistics
    {
        public long m_bytesSent;
        public long m_numSends;
        public long m_bytesReceived;
        public long m_bytesResent;
        public long m_bytesLost;

        public long m_numResends;
        private int m_numAcks;

        public DateTime m_openedTime { get; set; }
        public DateTime m_lastRecvTime { get; set; }
        public DateTime m_lastSendTime { get; set; }

        internal void incrementSent(ushort increment)
        {
            m_lastSendTime = DateTime.Now;
            m_bytesSent += increment;
            m_numSends++;
        }

        internal void incrementReceived(int len)
        {
            m_lastRecvTime = DateTime.Now;
            m_bytesReceived += len;
        }

        internal void incrementResent(ushort increment)
        {
            m_bytesResent += increment;
            ++m_numResends;
        }

        internal void incrementLost(int p)
        {
            m_bytesLost += p;
        }

        public override string ToString()
        {
            String str = "Stats Sent=" + m_bytesSent + " Received=" + m_bytesReceived + " Resent=" + m_bytesResent + " NumResent=" + m_numResends + " Lost=" + m_bytesLost;
            return str;
        }

        internal void incrementAcks()
        {
            ++m_numAcks;
        }
    }
}
